//
//  ViewController.m
//  OCUIBootcamp
//
//  Created by 周晓旺 on 2023/11/29.
//

#import "ViewController.h"
#import <Masonry.h>
#import "ResponderChain/ResponderChainBootcampViewController.h"
#import "ResponderChain/ResponderChainAdvancedViewController.h"
#import "ResponderChain/ResponderChainAdvancedTwoViewController.h"
@interface ViewController ()<UITableViewDataSource,UITableViewDelegate>
@property (nonatomic,strong) NSArray *dataArr;
@end


#define K_screenWidth UIScreen.mainScreen.bounds.size.width
#define K_screenHeight UIScreen.mainScreen.bounds.size.height
@implementation ViewController

static NSString *cellIdentifier = @"cellIdentifier";
- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
    self.dataArr = @[@"ResponderChainBootcamp",@"ResponderChainAdvanced",@"ResponderChainAdvancedTwo"];
    
    UITableView *tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, UIScreen.mainScreen.bounds.size.width, UIScreen.mainScreen.bounds.size.height) style:UITableViewStylePlain];
    [self.view addSubview:tableView];
    [tableView registerClass:[UITableViewCell class] forCellReuseIdentifier:cellIdentifier];
    tableView.dataSource = self;
    tableView.delegate = self;
    
}
//MARK: - dataSource
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return  self.dataArr.count;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier];
    NSString *title = self.dataArr[indexPath.row];
    cell.textLabel.text = title;
    return cell;
}
//MARK: - delegate
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    NSString *title = self.dataArr[indexPath.row];
    if ([title isEqualToString:@"ResponderChainBootcamp"]) { //开发中遇到过的因响应者链原因，点击后无法响应的问题
        ResponderChainBootcampViewController *vc = [[ResponderChainBootcampViewController alloc] init];
        [self.navigationController pushViewController:vc animated:true];
    }
    if ([title isEqualToString:@"ResponderChainAdvanced"]) {
        ResponderChainAdvancedViewController *vc = [[ResponderChainAdvancedViewController alloc] init];
        [self.navigationController pushViewController:vc animated:YES];
    }
    if ([title isEqualToString:@"ResponderChainAdvancedTwo"]) {
        ResponderChainAdvancedTwoViewController *vc = [[ResponderChainAdvancedTwoViewController alloc] init];
        [self.navigationController pushViewController:vc animated:YES];
    }
    
}

@end
